package com.hfi.ood.srp.bad;

/**
 * @author ChangLiang
 * @date 2020/5/12
 */
public class CourseService {

    /**
     * student choose a courseOffering
     * @param student
     * @param courseOffering
     */
    public void chooseCourse(Student student, CourseOffering courseOffering) {
        // if this student has taken pre required courses and this courseOffering is not full
        if (student.getCoursesAlreadyTaken().containsAll(courseOffering.getCourse().getPrerequisites())
                && courseOffering.getMaxStudent() > courseOffering.getStudents().size()
        ) {
            courseOffering.getStudents().add(student);
        }
    }
}
